package com.aishua.fire.jpa;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.aishua.fire.jpa.entity.AccountteamPermteam;
import com.aishua.fire.jpa.entity.AccountteamPermteamId;

public interface AccountteamPermteamDao extends JpaRepository<AccountteamPermteam, AccountteamPermteamId>,JpaSpecificationExecutor<AccountteamPermteam> {
	//根据accountteamId查询账户组-权限组表信息
	 @Transactional
	 @Query(value = "SELECT b.*,c.perm_team_name FROM accountteam a,accountteam_permteam b,permteam c WHERE a.`accountteam_id`=b.`accountteam_id` "
	 		+ "AND c.permteam_id=b.permteam_id and c.status=0 and a.accountteam_id=?1",nativeQuery=true)
	 List<Object> findByAccountteamId(Long accountteamId);
	 
	 	
	 @Transactional
	 @Query(value = "select ateampteam from AccountteamPermteam ateampteam where ateampteam.accountteamPermteamId.permteamId = ?1 and ateampteam.authType = ?2 ")
	 List<AccountteamPermteam> getAccountteamPermteamByPermteamId(long permteamId,String authType);
}
